!-------------------------------------------------------------LICENSE--------------------------------------------------------------!
!                                                                                                                                  !
!The MAP code is written in Fortran language for magnetohydrodynamics (MHD) calculation with the adaptive mesh refinement (AMR)    !
!and Message Passing Interface (MPI) parallelization.                                                                              !
!                                                                                                                                  !
!Copyright (C) 2012                                                                                                                !
!Ronglin Jiang                                                                                                                     !
!rljiang@ssc.net.cn                                                                                                                !
!585 Guoshoujing Road. Pudong, Shanghai, P.R.C. 201203                                                                             !
!                                                                                                                                  !
!This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License         !
!as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.             !
!                                                                                                                                  !
!This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of    !
!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.                        !
!                                                                                                                                  !
!You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software     !
!Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.                                                   !
!                                                                                                                                  !
!-------------------------------------------------------------LICENSE--------------------------------------------------------------!

!==================================================================================================================================|
subroutine block_shareblock (current, ro_flag, mx_flag, my_flag, mz_flag, bx_flag, by_flag, bz_flag, en_flag, az_flag, po_flag)
!==================================================================================================================================|

   use parameters
   use block_define
   use interface_block_boundary_physi
   implicit none

   logical(4), optional :: ro_flag, mx_flag, my_flag, mz_flag, bx_flag, by_flag, bz_flag, en_flag, az_flag, po_flag
   type(block), pointer, intent(inout) :: current

   integer(4) :: i, j, level, i_n, j_n, i_neigh, j_neigh
   integer(4) :: nx_bnd, ny_bnd, start_x, start_y
   integer(4) :: nx_tmp, ny_tmp, i_end, j_end
   real(8) :: dt_dx, dt_dy
   real(8), dimension(ng + 1, ny_no_bnd / ratio + 2 * ng) ::                                                                       &
      ro_bnd_x, mx_bnd_x, my_bnd_x, mz_bnd_x, bx_bnd_x, by_bnd_x, bz_bnd_x, en_bnd_x, az_bnd_x, po_bnd_x
   real(8), dimension(nx_no_bnd / ratio + 2 * ng, ng + 1) ::                                                                       &
      ro_bnd_y, mx_bnd_y, my_bnd_y, mz_bnd_y, bx_bnd_y, by_bnd_y, bz_bnd_y, en_bnd_y, az_bnd_y, po_bnd_y

!   real(8), dimension(nx_block, ny_block) :: vx_c, vy_c, vz_c, pr_c, te_c, vx_p, vy_p, vz_p, pr_p, te_p
!   real(8), dimension(ng + 1, ny_no_bnd / ratio + 2 * ng) :: vx_bnd_x, vy_bnd_x, vz_bnd_x, te_bnd_x
!   real(8), dimension(nx_no_bnd / ratio + 2 * ng, ng + 1) :: vx_bnd_y, vy_bnd_y, vz_bnd_y, te_bnd_y

   type(block), pointer :: parent, neigh

!----------------------------------------------------------------------------------------------------------------------------------|
   dt_dx = min_dt / current%dx
   dt_dy = min_dt / current%dy
   level = current%lv
   if (level .ne. 1) then
      parent => current%parent
      if (parent%cpu_id .ne. cpu_id) return
   else
      return
   endif

!   call variables_transform (vx_p, vy_p, vz_p, pr_p, te_p,                                                                         &
!      parent%ro, parent%mx, parent%my, parent%mz, parent%bx, parent%by, parent%bz, parent%en,                                      &
!      gm, nx_block, ny_block, 1)

!   call variables_transform (vx_c, vy_c, vz_c, pr_c, te_c,                                                                         &
!      current%ro, current%mx, current%my, current%mz, current%bx, current%by, current%bz, current%en,                              &
!      gm, nx_block, ny_block, 1)

!----------------------------------------------------------------------------------------------------------------------------------|
!  left boundary
!----------------------------------------------------------------------------------------------------------------------------------|
   i_neigh = -1
   j_neigh = 0
   neigh => current%neigh(i_neigh, j_neigh)%pblock
   if (associated(neigh)) then
      if (neigh%lv .eq. level - 1) then
         i_end = ng + 1
         j_end = ny_no_bnd / ratio + ng * 2
         ny_tmp = (current%p_pos(2) - 1) * ny_no_bnd / ratio
         do j = 1, j_end
            j_n = ny_tmp + j
            do i = 1, i_end
               if (present(ro_flag)) ro_bnd_x(i, j) = parent%ro(i, j_n)
               if (present(mx_flag)) mx_bnd_x(i, j) = parent%mx(i, j_n)
               if (present(my_flag)) my_bnd_x(i, j) = parent%my(i, j_n)
               if (present(mz_flag)) mz_bnd_x(i, j) = parent%mz(i, j_n)
!               if (present(mx_flag)) vx_bnd_x(i, j) = vx_p(i, j_n)
!               if (present(my_flag)) vy_bnd_x(i, j) = vy_p(i, j_n)
!               if (present(mz_flag)) vz_bnd_x(i, j) = vz_p(i, j_n)
               if (present(bx_flag)) bx_bnd_x(i, j) = parent%bx(i, j_n)
               if (present(by_flag)) by_bnd_x(i, j) = parent%by(i, j_n)
               if (present(bz_flag)) bz_bnd_x(i, j) = parent%bz(i, j_n)
               if (present(en_flag)) en_bnd_x(i, j) = parent%en(i, j_n)
!               if (present(en_flag)) te_bnd_x(i, j) = te_p(i, j_n)
               if (present(az_flag)) az_bnd_x(i, j) = parent%az(i, j_n)
               if (present(po_flag)) po_bnd_x(i, j) = parent%po(i, j_n)
            enddo
         enddo

         start_x = (ng + 1) * (ratio - 1)
         start_y = (ng + 1) * (ratio - 1)
         nx_bnd = ng + 1
         ny_bnd = ny_no_bnd / ratio + 2 * ng
         if (present(ro_flag)) call block_interpolate (current%ro(1 : ng, :), ng, ny_block,                                       &
            ro_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(mx_flag)) call block_interpolate (current%mx(1 : ng, :), ng, ny_block,                                       &
            mx_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(my_flag)) call block_interpolate (current%my(1 : ng, :), ng, ny_block,                                       &
            my_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(mz_flag)) call block_interpolate (current%mz(1 : ng, :), ng, ny_block,                                       &
            mz_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
!         if (present(mx_flag)) call block_interpolate (vx_c(1 : ng, :), ng, ny_block,                                       &
!            vx_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
!         if (present(my_flag)) call block_interpolate (vy_c(1 : ng, :), ng, ny_block,                                       &
!            vy_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
!         if (present(mz_flag)) call block_interpolate (vz_c(1 : ng, :), ng, ny_block,                                       &
!            vz_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(bx_flag)) call block_interpolate (current%bx(1 : ng, :), ng, ny_block,                                       &
            bx_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(by_flag)) call block_interpolate (current%by(1 : ng, :), ng, ny_block,                                       &
            by_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(bz_flag)) call block_interpolate (current%bz(1 : ng, :), ng, ny_block,                                       &
            bz_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(en_flag)) call block_interpolate (current%en(1 : ng, :), ng, ny_block,                                       &
            en_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
!         if (present(en_flag)) call block_interpolate (te_c(1 : ng, :), ng, ny_block,                                       &
!            te_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(az_flag)) call block_interpolate (current%az(1 : ng, :), ng, ny_block,                                       &
            az_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(po_flag)) call block_interpolate (current%po(1 : ng, :), ng, ny_block,                                       &
            po_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
      endif
   endif

!----------------------------------------------------------------------------------------------------------------------------------|
!  right boundary
!----------------------------------------------------------------------------------------------------------------------------------|
   i_neigh = 1
   j_neigh = 0
   neigh => current%neigh(i_neigh, j_neigh)%pblock
   if (associated(neigh)) then
      if(neigh%lv .eq. level - 1) then
         i_end = ng + 1
         j_end = ny_no_bnd / ratio + ng * 2
         ny_tmp = (current%p_pos(2) - 1) * ny_no_bnd / ratio
         do j = 1, j_end
            j_n = j + ny_tmp
            do i = 1, i_end
               i_n = parent%nx - ng - 1 + i
               if (present(ro_flag)) ro_bnd_x(i, j) = parent%ro(i_n, j_n)
               if (present(mx_flag)) mx_bnd_x(i, j) = parent%mx(i_n, j_n)
               if (present(my_flag)) my_bnd_x(i, j) = parent%my(i_n, j_n)
               if (present(mz_flag)) mz_bnd_x(i, j) = parent%mz(i_n, j_n)
!               if (present(mx_flag)) vx_bnd_x(i, j) = vx_p(i_n, j_n)
!               if (present(my_flag)) vy_bnd_x(i, j) = vy_p(i_n, j_n)
!               if (present(mz_flag)) vz_bnd_x(i, j) = vz_p(i_n, j_n)
               if (present(bx_flag)) bx_bnd_x(i, j) = parent%bx(i_n, j_n)
               if (present(by_flag)) by_bnd_x(i, j) = parent%by(i_n, j_n)
               if (present(bz_flag)) bz_bnd_x(i, j) = parent%bz(i_n, j_n)
               if (present(en_flag)) en_bnd_x(i, j) = parent%en(i_n, j_n)
!               if (present(en_flag)) te_bnd_x(i, j) = te_p(i_n, j_n)
               if (present(az_flag)) az_bnd_x(i, j) = parent%az(i_n, j_n)
               if (present(po_flag)) po_bnd_x(i, j) = parent%po(i_n, j_n)
            enddo
         enddo

         start_x = ratio + 1
         start_y = (ng + 1) * (ratio - 1)
         nx_bnd = ng + 1
         ny_bnd = ny_no_bnd / ratio + 2 * ng
         nx_tmp = nx_block - ng + 1

         if (present(ro_flag)) call block_interpolate (current%ro(nx_tmp : nx_block, :), ng, ny_block,                            &
            ro_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(mx_flag)) call block_interpolate (current%mx(nx_tmp : nx_block, :), ng, ny_block,                            &
            mx_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(my_flag)) call block_interpolate (current%my(nx_tmp : nx_block, :), ng, ny_block,                            &
            my_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(mz_flag)) call block_interpolate (current%mz(nx_tmp : nx_block, :), ng, ny_block,                            &
            mz_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
!         if (present(mx_flag)) call block_interpolate (vx_c(nx_tmp : nx_block, :), ng, ny_block,                            &
!            vx_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
!         if (present(my_flag)) call block_interpolate (vy_c(nx_tmp : nx_block, :), ng, ny_block,                            &
!            vy_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
!         if (present(mz_flag)) call block_interpolate (vz_c(nx_tmp : nx_block, :), ng, ny_block,                            &
!            vz_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(bx_flag)) call block_interpolate (current%bx(nx_tmp : nx_block, :), ng, ny_block,                            &
            bx_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(by_flag)) call block_interpolate (current%by(nx_tmp : nx_block, :), ng, ny_block,                            &
            by_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(bz_flag)) call block_interpolate (current%bz(nx_tmp : nx_block, :), ng, ny_block,                            &
            bz_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(en_flag)) call block_interpolate (current%en(nx_tmp : nx_block, :), ng, ny_block,                            &
            en_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
!         if (present(en_flag)) call block_interpolate (te_c(nx_tmp : nx_block, :), ng, ny_block,                            &
!            te_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(az_flag)) call block_interpolate (current%az(nx_tmp : nx_block, :), ng, ny_block,                            &
            az_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(po_flag)) call block_interpolate (current%po(nx_tmp : nx_block, :), ng, ny_block,                            &
            po_bnd_x, nx_bnd, ny_bnd, start_x, start_y, ratio)
      endif
   endif

!----------------------------------------------------------------------------------------------------------------------------------|
!  bottom boundary
!----------------------------------------------------------------------------------------------------------------------------------|
   i_neigh = 0
   j_neigh = -1
   neigh => current%neigh(i_neigh, j_neigh)%pblock
   if (associated(neigh)) then
      if(neigh%lv .eq. level - 1) then
         i_end = nx_no_bnd / ratio + ng * 2
         j_end = ng + 1
         nx_tmp = (current%p_pos(1) - 1) * nx_no_bnd / ratio
         do j = 1, j_end
            do i = 1, i_end
               i_n = i + nx_tmp
               if (present(ro_flag)) ro_bnd_y(i, j) = parent%ro(i_n, j)
               if (present(mx_flag)) mx_bnd_y(i, j) = parent%mx(i_n, j)
               if (present(my_flag)) my_bnd_y(i, j) = parent%my(i_n, j)
               if (present(mz_flag)) mz_bnd_y(i, j) = parent%mz(i_n, j)
!               if (present(mx_flag)) vx_bnd_y(i, j) = vx_p(i_n, j)
!               if (present(my_flag)) vy_bnd_y(i, j) = vy_p(i_n, j)
!               if (present(mz_flag)) vz_bnd_y(i, j) = vz_p(i_n, j)
               if (present(bx_flag)) bx_bnd_y(i, j) = parent%bx(i_n, j)
               if (present(by_flag)) by_bnd_y(i, j) = parent%by(i_n, j)
               if (present(bz_flag)) bz_bnd_y(i, j) = parent%bz(i_n, j)
               if (present(en_flag)) en_bnd_y(i, j) = parent%en(i_n, j)
!               if (present(en_flag)) te_bnd_y(i, j) = te_p(i_n, j)
               if (present(az_flag)) az_bnd_y(i, j) = parent%az(i_n, j)
               if (present(po_flag)) po_bnd_y(i, j) = parent%po(i_n, j)
            enddo
         enddo

         start_x = (ng + 1) * (ratio - 1)
         start_y = (ng + 1) * (ratio - 1)
         nx_bnd = nx_no_bnd / ratio + 2 * ng
         ny_bnd = ng + 1

         if (present(ro_flag)) call block_interpolate (current%ro(:, 1 : ng), nx_block, ng,                                       &
            ro_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(mx_flag)) call block_interpolate (current%mx(:, 1 : ng), nx_block, ng,                                       &
            mx_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(my_flag)) call block_interpolate (current%my(:, 1 : ng), nx_block, ng,                                       &
            my_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(mz_flag)) call block_interpolate (current%mz(:, 1 : ng), nx_block, ng,                                       &
            mz_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
!         if (present(mx_flag)) call block_interpolate (vx_c(:, 1 : ng), nx_block, ng,                                       &
!            vx_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
!         if (present(my_flag)) call block_interpolate (vy_c(:, 1 : ng), nx_block, ng,                                       &
!            vy_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
!         if (present(mz_flag)) call block_interpolate (vz_c(:, 1 : ng), nx_block, ng,                                       &
!            vz_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(bx_flag)) call block_interpolate (current%bx(:, 1 : ng), nx_block, ng,                                       &
            bx_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(by_flag)) call block_interpolate (current%by(:, 1 : ng), nx_block, ng,                                       &
            by_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(bz_flag)) call block_interpolate (current%bz(:, 1 : ng), nx_block, ng,                                       &
           bz_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
!         if (present(en_flag)) call block_interpolate (current%en(:, 1 : ng), nx_block, ng,                                       &
!            en_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
!         if (present(en_flag)) call block_interpolate (te_c(:, 1 : ng), nx_block, ng,                                       &
!            te_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(en_flag)) call block_interpolate (current%en(:, 1 : ng), nx_block, ng,                                       &
            en_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(az_flag)) call block_interpolate (current%az(:, 1 : ng), nx_block, ng,                                       &
            az_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(po_flag)) call block_interpolate (current%po(:, 1 : ng), nx_block, ng,                                       &
            po_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
      endif

   endif

!----------------------------------------------------------------------------------------------------------------------------------|
!  top boundary
!----------------------------------------------------------------------------------------------------------------------------------|
   i_neigh = 0
   j_neigh = 1
   neigh => current%neigh(i_neigh, j_neigh)%pblock
   if (associated(neigh)) then
      if(neigh%lv .eq. level - 1) then
         i_end = nx_no_bnd / ratio + ng * 2
         j_end = ng + 1
         nx_tmp = (current%p_pos(1) - 1) * nx_no_bnd / ratio
         do j = 1, j_end
            j_n = parent%ny - ng - 1 + j
            do i = 1, i_end
               i_n = i + nx_tmp
               if (present(ro_flag)) ro_bnd_y(i, j) = parent%ro(i_n, j_n)
               if (present(mx_flag)) mx_bnd_y(i, j) = parent%mx(i_n, j_n)
               if (present(my_flag)) my_bnd_y(i, j) = parent%my(i_n, j_n)
               if (present(mz_flag)) mz_bnd_y(i, j) = parent%mz(i_n, j_n)
!               if (present(mx_flag)) vx_bnd_y(i, j) = vx_p(i_n, j_n)
!               if (present(my_flag)) vy_bnd_y(i, j) = vy_p(i_n, j_n)
!               if (present(mz_flag)) vz_bnd_y(i, j) = vz_p(i_n, j_n)
               if (present(bx_flag)) bx_bnd_y(i, j) = parent%bx(i_n, j_n)
               if (present(by_flag)) by_bnd_y(i, j) = parent%by(i_n, j_n)
               if (present(bz_flag)) bz_bnd_y(i, j) = parent%bz(i_n, j_n)
               if (present(en_flag)) en_bnd_y(i, j) = parent%en(i_n, j_n)
!               if (present(en_flag)) te_bnd_y(i, j) = te_p(i_n, j_n)
               if (present(az_flag)) az_bnd_y(i, j) = parent%az(i_n, j_n)
               if (present(po_flag)) po_bnd_y(i, j) = parent%po(i_n, j_n)
            enddo
         enddo

         start_x = (ng + 1) * (ratio - 1)
         start_y = ratio + 1
         nx_bnd = nx_no_bnd / ratio + 2 * ng
         ny_bnd = ng + 1
         ny_tmp = ny_block - ng + 1

         if (present(ro_flag)) call block_interpolate (current%ro(:, ny_tmp : ny_block), nx_block, ng,                            &
            ro_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(mx_flag)) call block_interpolate (current%mx(:, ny_tmp : ny_block), nx_block, ng,                            &
            mx_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(my_flag)) call block_interpolate (current%my(:, ny_tmp : ny_block), nx_block, ng,                            &
            my_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(mz_flag)) call block_interpolate (current%mz(:, ny_tmp : ny_block), nx_block, ng,                            &
            mz_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
!         if (present(mx_flag)) call block_interpolate (vx_c(:, ny_tmp : ny_block), nx_block, ng,                            &
!            vx_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
!         if (present(my_flag)) call block_interpolate (vy_c(:, ny_tmp : ny_block), nx_block, ng,                            &
!            vy_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
!         if (present(mz_flag)) call block_interpolate (vz_c(:, ny_tmp : ny_block), nx_block, ng,                            &
!            vz_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(bx_flag)) call block_interpolate (current%bx(:, ny_tmp : ny_block), nx_block, ng,                            &
            bx_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(by_flag)) call block_interpolate (current%by(:, ny_tmp : ny_block), nx_block, ng,                            &
            by_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(bz_flag)) call block_interpolate (current%bz(:, ny_tmp : ny_block), nx_block, ng,                            &
            bz_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(en_flag)) call block_interpolate (current%en(:, ny_tmp : ny_block), nx_block, ng,                            &
            en_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)

!         if (present(en_flag)) call block_interpolate (te_c(:, ny_tmp : ny_block), nx_block, ng,                            &
!            te_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(az_flag)) call block_interpolate (current%az(:, ny_tmp : ny_block), nx_block, ng,                            &
            az_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
         if (present(po_flag)) call block_interpolate (current%po(:, ny_tmp : ny_block), nx_block, ng,                            &
            po_bnd_y, nx_bnd, ny_bnd, start_x, start_y, ratio)
      endif
   endif

!      if (all (reshape (current%id, (/6/)) .eq. (/3,3,1,2,2,2/)) .and. ns_hc .eq. 11 .and. ns .eq. 39) then
!!         print*, real(current%en(5:20,5:20))
!!         print*, real(current%en(:,21:24))
!!         print*, real (current%parent%en(:,20:24))
!         print*, en_bnd_y
!         print*, real (current%en(:,21:24))
!         pause
!      endif
!   call variables_transform (vx_c, vy_c, vz_c, pr_c, te_c,                                                                         &
!      current%ro, current%mx, current%my, current%mz, current%bx, current%by, current%bz, current%en,                              &
!      gm, nx_block, ny_block, 2)

!----------------------------------------------------------------------------------------------------------------------------------|
   return
end subroutine block_shareblock
